import tile

class Sheet():
    """Sheet of tiles with configurable width and height"""
    
    def __init__(self, width, height):
        """Sets up width and height of sheet measured in tiles"""
        self._width = width
        self._height = height
        self._array = [[None for col in range(width)] for row in range(height)]
        
    def draw(self):
        """Calls draw() on each contained tile"""
        for i in range(self._height):
            for j in range(self._width):
                self._array[i][j].draw()
    
    def update(self, all=False):
        """Updates contained tiles.
        
        :param all: True indicates even background tiles should be updated
            (default False)
        """ 
        for i in range(self._height):
            for j in range(self._width):                    
                if all or self._array[i][j].is_active():
                    self._array[i][j].update()